<template>
  <view
    class="content"
    :style="{
      'padding-top': height + 'px',
    }"
  >
    <view
      :style="{
        height: statusBarHeight + 'px',
      }"
    >
    </view>
    <!-- 头部 -->
    <view
      class="head"
      :style="{
        top: statusBarHeight + 'px',
        background: isHeadBack ? 'rgba(0,0,0,0.3)' : 'rgba(0,0,0,0)',
      }"
    >
      <view class="head_left">
        <u-icon
          name="arrow-left"
          color="#EEEEEE"
          size="24"
          :bold="true"
          @click="toBack"
        ></u-icon>
      </view>
      <view class="text">兑换码</view>
      <view class="head_right" @click="goRecord">兑换记录</view>
    </view>

    <view class="box">
      <view class="box_item">
        <u--input
          class="box_item_input"
          placeholder="请填写兑换码进行兑换"
          border="none"
          v-model="value1"
          placeholderStyle="color:#888888"
          color="#888888"
        ></u--input>
      </view>
    </view>

    <view class="bottom">
      <view class="bottom_btn" @click="subFn">确认兑换</view>
    </view>


    <floatingBall></floatingBall>
  </view>
</template>
            
            <script>
export default {
  components: {},

  data() {
    return {
      statusBarHeight: 0,
      height: 0,
      isHeadBack: false,
      value1: "",
      value2: "",
      List1: [
        {
          name: "积分",
        },
        {
          name: "人民币",
        },
        {
          name: "牛勒",
        },
      ],
      List2: [
        {
          name: "积分",
        },
        {
          name: "人民币",
        },
        {
          name: "牛勒",
        },
      ],
      show1: false,
      show2: false,
      title1: "积分",
      title2: "人民币",
    };
  },
  created() {
    const statusBarHeight = uni.getSystemInfoSync(); // 获取手机状态栏高度

    this.statusBarHeight = statusBarHeight.statusBarHeight;
    this.$nextTick(() => {
      uni
        .createSelectorQuery()
        .select(".head")
        .boundingClientRect((data) => {
          this.height = data.height;
        })
        .exec();
    });
  },
  methods: {
    toBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
    // 兑换记录
    goRecord(){
      uni.navigateTo({
        url: "/pages/integral/exchangeRecords",
      });
      
    },
    selectClick1(a) {
      this.title1 = a.name;
      console.log(a.name);
      this.show1 = false;
    },
    selectClick2(a) {
      this.title2 = a.name;
      console.log(a.name);
      this.show2 = false;
    },
    goPage() {
      uni.navigateTo({
        url: "/pages/integral/codeRecord",
      });
    },
    subFn() {
      if (this.value1 == "") {
        uni.$u.toast("请输入兑换码");
        return;
      }
      this.getOrderDuihuan()
    },
    getOrderDuihuan() {
      this.$http
        .orderDuihuan({code:this.value1})
        .then((res) => {
          console.log(res, "兑换码");
          uni.$u.toast(res.message);
        })
        .catch((error) => {
          uni.$u.toast(error);
        });
    },
  },
};
</script>
            
            <style scoped lang="scss">
.content {
  background: #111111;
  box-sizing: border-box;
  // background: url("/static/images/my/pic_wdjf_bwijing.png") no-repeat;
  // background-size: 100% auto;
  // background-attachment: fixed;
  z-index: -10;
  display: flex;
  flex-direction: column;
}

.head {
  width: 100%;
  padding: 18rpx 30rpx 47rpx;
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  z-index: 99;
  background: #ffffff;
  .head_left {
    position: absolute;
    left: 30rpx;
  }

  .head_right {
    position: absolute;
    right: 30rpx;
    color: #55b877;
    font-size: 30rpx;
  }

  .text {
    font-size: 36rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: 400;
    color: #eeeeee;
  }
}
.box {
  padding: 30rpx 60rpx;
  .box_item {
    background: #272c29;
    border-radius: 48rpx;
    padding: 26rpx 40rpx;
    display: flex;
    align-items: center;
    .box_item_title {
      font-size: 30rpx;
      color: #ffffff;
      display: flex;
      align-items: center;
      .u-icon {
        margin-left: 12rpx;
        position: relative;
        top: 3rpx;
      }
    }
    /deep/.u-line {
      margin-left: 23rpx !important;
    }
    .box_item_input {
      margin-left: 23rpx !important;
    }
  }
  .box_item_text {
    font-size: 24rpx;
    color: #adadad;
    margin-top: 24rpx;
    padding-left: 40rpx;
    margin-bottom: 56rpx;
  }
}
.bottom {
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 0 60rpx;
  box-sizing: border-box;
  margin-bottom: 80rpx;
  .bottom_btn {
    width: 100%;
    height: 96rpx;
    background: linear-gradient(360deg, #50b674 0%, #aeddbd 100%);
    border-radius: 48rpx;
    text-align: center;
    line-height: 96rpx;
    color: #ffffff;
  }
}
</style>